/**
 * Created by dukes on 2016/3/2.
 */
class GuildMember extends eui.Component {
    public constructor() {
        super();
        this.skinName = "skins.scene.GuildMemberSkin";
        this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAdded, this );
    }
    private onAdded(evt:egret.Event){
        window["__memberList"]();
    }
    public onListBack(list){
        this.provider.source = list;
    }
    public onKickBack(userId){
        var list = this.provider.source;
        var len = list.length;
        var data;
        for(var i = 0; i < len; i++){
            data = list[i];
            if( data.userId == userId){
                this.provider.removeItemAt(i);
                break;
            }
        }
    }
    private provider:eui.ArrayCollection;
    public member_list:eui.List;
    public partAdded(name:string, instance:any) {
        super.partAdded(name, instance);
        if (name == "member_list") {
            this.member_list = instance;
            this.member_list.itemRenderer = GuildMemberItemRender;
            this.provider = new eui.ArrayCollection();
            this.member_list.dataProvider = this.provider;
        }
    }
    private static _instance:GuildMember;
    public static getInstance():GuildMember{
        if( GuildMember._instance == null)
            GuildMember._instance = new GuildMember();
        return GuildMember._instance;
    }
}